using System;
using System.Collections.Generic;
using System.Text;

using libsecondlife;
using libsecondlife.InventorySystem;

using Feathertail;

namespace NestBox.Inventory
{
    class mkdir : Feathertail.Command
    {
        FeathertailClient _Client;

        #region Command Members

        public void Setup(FeathertailClient Client)
        {
            _Client = Client;
        }

        public string HandleInput(string[] CmdLine)
        {
            if (CmdLine.Length < 2)
            {
                return GetHelpText();
            }

            string targetDir = NestBox.Inventory.Helpers.combineCmdArg(CmdLine);

            string curDirectory = (string)_Client.FeathertailState[Helpers.CurrentDirectoryKey];
            InventoryFolder iFolder = _Client.Inventory.getFolder(curDirectory);

            InventoryFolder newFolder = iFolder.CreateFolder(targetDir);

            if (newFolder != null)
            {
                return "Directory created: " + targetDir;
            }
            else
            {
                return "Error creating directory: " + targetDir;
            }
        }

        public string[] GetCommandStrings()
        {
            return new string[] { "mkdir" };
        }

        public string GetSummaryText()
        {
            return "Create a folder in your inventory";
        }

        public string GetHelpText()
        {
            return "Usage: mkdir [directory]";
        }

        #endregion
    }
}
